/*
 * Copyright (c) 2015 Messcat. All rights reserved.
 */
package cc.messcat.common.dao;

import cc.messcat.common.model.Pager;

import java.util.List;
import java.util.Map;

public interface BaseDao<T> {

    <K> K get(Class<K> clazz, final long id);

    T get(final long id);

    <K> List<K> getAll(Class<K> clazz);

    List<T> getAll();

    void save(final Object entity);

    Long save1(final Object entity);

    <K> K update(final K entity);

    void delete(final Object entity);

    <K> void deleteById(Class<K> clazz, final long entityId);

    void deleteById(final long entityId);

    <K> K getByState(Class<K> clazz, final long id);

    T getByState(final long id);

    <K> List<K> getAllByState(Class<K> clazz);

    List<T> getAllByState();

    <K> List<K> findByExample(K entity);

    /**
     * 分页查找
     *
     * @param pageNo   页数
     * @param pageSize 每页数量
     * @param hql      查询语句
     * @param attrs
     * @return
     */
    Pager<T> getPagerByHql(int pageNo, int pageSize, String hql, Object... attrs);

    void modifyByHql(String sql);

    Pager getPagerByHql(Integer pageNo, Integer pageSize, String hql, Map attrs);

    public List queryList(String hql, Map map);

    public List find(String hql);

    public List<T> findPageObjects(String hql, int pageNo, int pageSize, final Object... conditions);

    Pager<T> getPagerByHql(String hql, String count, Integer pageNo, Integer pageSize, Map condition);

    public List<Map<String, Object>> findToMapBySql(String sql, Object... args);
}
